<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
	<script src="js/axios.min.js"></script>
	<script src="js/vue.min.js"></script>
</head>
<body>
<div id="app">
	<h3>Photo用户登录2222222222 11111111</h3>
	<p v-if="loginedUser">
		你好{{loginedUser}}
		<a href="logout.s">退出</a>
	</p>
	<p v-else>未登录</p>
	<form action="login.s" method="get">
		账号：<input v-model="user.username"><br>
		密码：<input v-model="user.password"><br>
		记住账号：<select>
			<option>忘了我吧</option>
			<option>1分钟</option>
			<option>1小时</option>
			<option>1天</option>
			<option>1周</option>
			<option>1月</option>
			<option>天荒地老</option>
		</select><br>
		<input type="submit" @click.prevent="login" value="提交"><br>
	</form>
</div>
<script>
	var v = new Vue({
		el : "#app",
		data : {
			user:{
				username : "",
				password : "",
			},
			loginedUser : ""
		},
		created(){
			// 打开页面获取登录用户信息
			axios.get("getLoginedUser.s").then(res=>{
				if(res.data.code == 1){
					this.loginedUser = res.data.data;
				} else {
					alert(res.data.msg);
				}
			})
		},
		methods:{
			login(){
				axios.get("login.s",{
					params : this.user
				}).then(res=>{
					if(res.data.code == 1){
						this.loginedUser = this.user.username;
					} else {
						alert(res.data.msg);
					}
				})
			}
		}
	})
</script>

</body>
</html>